package com.example.demo.enums;

public enum UserStatus {

    DISABLED(-1, "禁用"),
    VALID(0, "可用");

    int value;
    String str;

    UserStatus(int value, String str) {
        this.value = value;
        this.str = str;
    }

    public int value() {
        return this.value;
    }

    public String toString() {
        return this.str;
    }

    public static UserStatus of(int val) {
        for (UserStatus value : UserStatus.values()) {
            if (value.value == val) {
                return value;
            }
        }
        return null;
    }

    public static UserStatus of(String name) {
        for (UserStatus value : UserStatus.values()) {
            if (value.str.equals(name)) {
                return value;
            }
        }
        return null;
    }

}
